﻿@*@{
    Layout = null;
    var plugName = @news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name;
    var tableName = PageViewModel.PageTableID(this, plugName);
    var tableToolBar = PageViewModel.PageTableToolbar(this, plugName);

    var editFunName = PageViewModel.PageFunctionName(this, "edit_archive_category", plugName);
    var editDlgName = PageViewModel.PageEditDialog(this, plugName);
    var saveEditFunName = PageViewModel.PageFunctionName(this, "save_archive_category", plugName);
    var deleteFunName = PageViewModel.PageFunctionName(this, "delete_archive_category", plugName);

}
<div style="height:100%">
    <script type="text/javascript">
        function @editFunName (id) {
            var dlg = $dlg('@editDlgName');
            dlg.dialog({
                title: '栏目类型', width: 700, height: 450, closed: false, cache: false, modal: true, maximizable: false, resizable: false, maximized: false,
                href: '~/@news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name/ArchiveCategorys/_EditArchiveCategoryDlg?ID='+id,
                onResize: function () {
                    $(this).dialog('center');
                },
                buttons: [
                    {
                        text: "保 存",
                        handler: function () { @saveEditFunName (); },
                        iconCls: "icon-save"
                    }, {
                        text: "取 消",
                        handler: function () {
                            $("#@editDlgName").dialog("close");
                        },
                        iconCls: "icon-cancel"
                    }
                ],
                onLoad: function () {
                    LoadObject(id, "~/@news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name/ArchiveCategorys/GetArchiveCategoryByID/", function (item) {
                            var form = $("#@editDlgName").find("form");
                            form.form("load", item);
                        });
                }
            });
        }

        function @saveEditFunName () {
            var form = $("#@editDlgName").find("form");
            if (form.form('enableValidation').form('validate')) {
                var menu = form.form_to_json();

                $.ajax({
                    url: "~/@news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name/ArchiveCategorys/SaveArchiveCategory",
                    type: "POST",
                    data: menu,
                    success: function (e) {
                        if (e.Result) {
                            $.messager.alert('保存成功', '保存成功!', 'info', function () {
                                $('#@editDlgName').dialog('close');
                                $('#@tableName').treegrid('reload');
                            });
                        } else {
                            $.messager.alert('保存失败', '保存失败: ' + e.Msg, 'error');
                        }
                    },
                    error: function (e) {
                        ShowAjaxError(e);
                    }
                });
            }
        }

        function @deleteFunName (id) {
            if (id > 0 && confirm("确认删除栏目信息?")) {
                $.ajax({
                    async: false,
                    method: "DELETE",
                    url: $.Content("~/@news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name/ArchiveCategorys/DeleteArchiveCategory/" + id),
                    context: $("#@tableName"),
                    success: function (e) {
                        if (e.Result) {
                            this.treegrid('remove', id);
                        } else {
                            $.messager.alert('删除数据错误', '删除失败: ' + e.Msg, 'error');
                        }
                    },
                    error: function (e1, e2, e3) {
                        ShowAjaxError(e1, "删除数据错误");
                        this.treegrid('reload');
                    }
                });
            }
        }

    </script>
    <table id="@tableName" class="easyui-treegrid" style="width:100%;" rownumbers="true" fit="true"
           pagination="true" pageSize="@SystemSettingService.Instance.PageSize" pageList="@SystemSettingService.Instance.PageList"
           data-options="striped:true,border:false,url: '~/@news.admin.cyt369.com.Areas.NewsAdmin.Models.PlugName.Name/ArchiveCategorys/GetArchiveCategorys',method:'get',idField: 'Id',treeField: 'Name',toolbar:'#@tableToolBar'">
        <thead>
            <tr>
                <th data-options="field:'_edit',align:'center',formatter:function(v,r,i){
                    return GridRowEditFmt('@editFunName', r.Id);
                }" width="45">修改</th>
                <th data-options="field:'_remove',align:'center',formatter:function(v,r,i){
                    return GridRowDeleteFmt('@deleteFunName', r.Id);
                }" width="45">删除</th>
                <th data-options="field:'Name'" width="250">名称</th>
                <th data-options="field:'Level'" width="100">层级</th>
                <th data-options="field:'URL'" width="100">链接</th>
                <th data-options="field:'Description'" width="250">说明</th>
                <th data-options="field:'Sequence',align:'center'" width="100">排序号</th>
            </tr>
        </thead>
    </table>
    <div id="@tableToolBar" class="table-toolbar">
        <a href="javascript:@editFunName ()" class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加</a>
    </div>
</div>*@
